package cn.fizzo.hub.sdk;

import android.os.Handler;
import android.os.Message;

import java.util.List;

import cn.fizzo.hub.sdk.array.NotifyActions;
import cn.fizzo.hub.sdk.entity.AntPlusInfo;

/**
 * Created by Raul.Fan on 2018/1/12.
 */

public class NotifyManager {


    private static NotifyManager instance;//唯一实例

    private NotifyManager() {

    }

    /**
     * 获取堆栈管理的单一实例
     */
    public static NotifyManager getManager() {
        if (instance == null) {
            instance = new NotifyManager();
        }
        return instance;
    }

    Handler mNotifyHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                //发布连接状态变化
                case NotifyActions.NOTIFY_NEW_ANT:
                    Fh.getManager().notifyNewAnts((List<AntPlusInfo>) msg.obj);
                    break;
            }
        }
    };

    /**
     * 发布实时心率数据
     */
    public synchronized void notifyNewAntsRealTimeHr(final List<AntPlusInfo> ants){
        Message msg = mNotifyHandler.obtainMessage(NotifyActions.NOTIFY_NEW_ANT);
        msg.obj = ants;
        mNotifyHandler.sendMessage(msg);
    }
}
